CtgCriterioVinculacion = function(){
	return{
		save: function(){
			Asg.Message.progress("Guardando Informaci\u00F3n...");
			Ext.getCmp("ctgCriterioVinculacionForm").getForm().submit({
    			url: Asg.constants.CONTEXT_PATH + "/admin/vinculacion/guardar",
    			timeout: Asg.constants.TIMEOUT_SECONDS,
    			success: function(form, action){
    				Asg.Message.confirmProcess(action.result.message, function(){
    					if(action.result.success){
    						Asg.Grid.clearSelection("ctgCriterioVinculacionGrid");
    						if(action.result.data) 
    							Asg.Grid.loadData("ctgCriterioVinculacionGrid", action.result.data);
    					}
    				});
    			},
    			failure: Asg.Form.failureProcedure
			});
		},
		getButtonsConfig: function(){
			return {
				add: "ctgCriterioVinculacionAddButton",
				edit: "ctgCriterioVinculacionEditButton",
				save: "ctgCriterioVinculacionSaveButton",
				cancel: "ctgCriterioVinculacionCancelButton"
			};
		},
		initConfig: function(config){
			return {
				items: [{
					xtype: "grid",
		        	id: "ctgCriterioVinculacionGrid",
		        	frame: true,
		        	margins: "5 5 5 5",
		        	height: 300,
		        	store: new Ext.data.SimpleStore({
		        		data: config.data || [],
		        		fields: [
							"ctgCriterioVinculacionId",
							"ctgCriterioVinculacionNombre",
							"ctgCriterioVinculacionDescripcion",
							"ctgCriterioVinculacionAccionSistema",
							"ctgCriterioVinculacionTipoCriterio",
							"ctgCriterioVinculacionCalificacion",
							"ctgCriterioVinculacionFuncion",
							"ctgCriterioVinculacionUso",
							"ctgCriterioVinculacionChequeado",
							"ctgCriterioVinculacionPrioridad"
    		            ]
		        	}),
	        		selModel: {
	        			listeners: {
	        				selectionchange: function(selectionModel, records){
	        					if(records && records.length > 0){
	        						
	        					}
	        				}
	        			}
	        		},
		        	columns: [
    	          		{header: "Nombre", dataIndex: "ctgCriterioVinculacionNombre", width: 200},
    	          		{header: "Descripcion", dataIndex: "ctgCriterioVinculacionDescripcion", flex: 1},
    	          		{header: "Accion del Sistema", dataIndex: "ctgCriterioVinculacionAccionSistema", width:100 },
    	          		{header: "Tipo Criterio", dataIndex: "ctgCriterioVinculacionTipoCriterio", width:75 },
    	          		{header: "Calificacion", dataIndex: "ctgCriterioVinculacionCalificacion", width:75 },
    	          		{header: "Funcion", dataIndex: "ctgCriterioVinculacionFuncion", width:200 },
    	          		{header: "Uso", dataIndex: "ctgCriterioVinculacionUso", width:75 },
    	          		{header: "Chequeado", dataIndex: "ctgCriterioVinculacionChequeado", width:75 },
    	          		{header: "Prioridad", dataIndex: "ctgCriterioVinculacionPrioridad", width:75 }
        	        ],
		        	bbar: [
						"->",
						{
							   id: "ctgCriterioVinculacionAddButton",
							   text: "Agregar", 
							   iconCls: Asg.constants.ADD_ICON,
							   handler: function(){
								   Asg.Form.switchButton(CtgCriterioVinculacion.getButtonsConfig(), "add");
								   Asg.Form.switchForm("ctgCriterioVinculacionForm", "add");
		        	    		   Asg.Grid.clearSelection("ctgCriterioVinculacionGrid");
							   }
						},{
							   id: "ctgCriterioVinculacionEditButton",
							   text: "Editar", 
							   iconCls: Asg.constants.EDIT_ICON,
							   hidden: true,
							   handler: function(){
								   Asg.Form.switchButton(CtgCriterioVinculacion.getButtonsConfig(), "edit");
	        	    			   Asg.Form.switchForm("ctgCriterioVinculacionForm", "edit");
							   }
						},{
							   id: "ctgCriterioVinculacionSaveButton",
							   text: "Guardar", 
							   iconCls: Asg.constants.SAVE_ICON,
							   hidden: true,
							   handler: CtgCriterioVinculacion.save
						},{
							   id: "ctgCriterioVinculacionCancelButton",
							   text: "Cancelar", 
							   iconCls: Asg.constants.CANCEL_ICON,
							   hidden: true,
							   handler: function(){
								   Asg.Form.switchButton(CtgCriterioVinculacion.getButtonsConfig(), "cancel");
	        	    			   Asg.Form.switchForm("ctgCriterioVinculacionForm", "cancel");
							   }
						} 
        	        ]
				},{
					xtype: "form",
	        		id: "ctgCriterioVinculacionForm",
	        		border: false,
	        		height: 450,
	        		layout: {
    	        		type: "table",
						columns: 4,
						tableAttrs: {
				            style: {width: "520px"},
				            align: "center"
						}
    	        	},
    	        	defaults: Asg.Form.defaults({width: 255, colspan: 2}),
    	        	items: [
        	        	{xtype: "label", text: "C\u00F3digo:", cls: "x-form-item", colspan: 4},
        	        	{
        	        		xtype: "textfield", 
        	        		id: "ctgCriterioVinculacionId",
        	        		name: "ctgCriterioVinculacionId",
        	        		maxLength: 20,
        	        		disabled: true,
        	        		maxLength: 20,
        	        		colspan: 4
    	        		},
    	        		{xtype: "label", text: "Nombre:", cls: "x-form-item", colspan: 2},
    	        		{xtype: "label", text: "Descripcion:", cls: "x-form-item", colspan: 2},
    	        		{
        	        		xtype: "textfield", 
        	        		id: "ctgCriterioVinculacionNombre",
        	        		name: "ctgCriterioVinculacionNombre",
        	        		allowBlank: false,
        	        		disabled: true,
        	        		colspan: 2
    	        		},
    	        		{
    	        			xtype: "textfield", 
    	        			id: "ctgCriterioVinculacionDescripcion",
    	        			name: "ctgCriterioVinculacionDescripcion",
    	        			allowBlank: false,
    	        			disabled: true,
    	        			colspan: 2
    	        		},
    	        		{xtype: "label", text: "Acci\u00F3n del Sistema:", cls: "x-form-item", colspan: 2},
    	        		{xtype: "label", text: "Tipo de Criterio:", cls: "x-form-item", colspan: 2},
    	        		{
    	        			xtype: "combo",
    	        			id: "ctgCriterioVinculacionAccionSistema",
    	        			name: "ctgCriterioVinculacionAccionSistema",
    	        			allowBlank: false,
    	        			disabled:false,
    	        			colspan:2,
	                        store: new Ext.data.SimpleStore({
	                        	data: [["1","CALIFICADO"],["2","FILTRO"]],
	                        	fields: ["id","value"]
	                        }),
	                        displayField: "value",
	                        valueField: "id"
    	        		},
    	        		{
    	        			xtype: "combo",
    	        			id: "ctgCriterioVinculacionTipoCriterio",
    	        			name: "ctgCriterioVinculacionTipoCriterio",
    	        			allowBlank: false,
    	        			disabled:false,
    	        			colspan:2,
	                        store: new Ext.data.SimpleStore({
	                        	data: [["1","FILTRO"],["2","CERRADO"],["3","RANGO"]],
	                        	fields: ["id","value"]
	                        }),
	                        displayField: "value",
	                        valueField: "id"
    	        		},
    	        		{xtype: "label", text: "Calificaci\u00F3n:", cls: "x-form-item", colspan: 2},
    	        		{xtype: "label", text: "Funcion:", cls: "x-form-item", colspan: 2},
    	        		{
        	        		xtype: "textfield", 
        	        		id: "ctgCriterioVinculacionCalificacion",
        	        		name: "ctgCriterioVinculacionCalificacion",
        	        		allowBlank: false,
        	        		disabled: true,
        	        		colspan: 2
    	        		},
    	        		{
        	        		xtype: "textfield", 
        	        		id: "ctgCriterioVinculacionFuncion",
        	        		name: "ctgCriterioVinculacionFuncion",
        	        		allowBlank: false,
        	        		disabled: true,
        	        		colspan: 2
    	        		},
    	        		{xtype: "label", text: "Uso:", cls: "x-form-item", colspan: 2},
    	        		{xtype: "label", text: "Prioridad:", cls: "x-form-item", colspan: 2},
    	        		{
    	        			xtype: "combo",
    	        			id: "ctgCriterioVinculacionUso",
    	        			name: "ctgCriterioVinculacionUso",
    	        			allowBlank: false,
    	        			disabled:false,
    	        			colspan:2,
	                        store: new Ext.data.SimpleStore({
	                        	data: [["1","INTERNO"],["2","WEB/INTERNO"]],
	                        	fields: ["id","value"]
	                        }),
	                        displayField: "value",
	                        valueField: "id"
    	        		},
    	        		{
        	        		xtype: "textfield", 
        	        		id: "ctgCriterioVinculacionPrioridad",
        	        		name: "ctgCriterioVinculacionPrioridad",
        	        		allowBlank: false,
        	        		disabled: true,
        	        		colspan: 2
    	        		},
    	        		{xtype: "label", text: "Chequeado:", cls: "x-form-item", colspan: 4},
    	        		{
    	        			xtype: "combo",
    	        			id: "ctgCriterioVinculacionChequeado",
    	        			name: "ctgCriterioVinculacionChequeado",
    	        			allowBlank: false,
    	        			width: 100,
    	        			disabled:false,
    	        			colspan:4,
	                        store: new Ext.data.SimpleStore({
	                        	data: [["1","SI"],["0","NO"]],
	                        	fields: ["id","value"]
	                        }),
	                        displayField: "value",
	                        valueField: "id"
    	        		}
    	        	]
				}]
			};
		}
	}; 
}();